import router from './router'
import store from './store'
router.beforeEach((to, from, next) => {
  const token = store.getters['user/token']
  if (to.meta?.needPermission) {
    if (token) {
      next()
    } else {
      next('/login')
    }
  } else {
    if (to.path === '/login' && token) {
      next('/mine')
    } else {
      next()
    }
  }
})
